package com.moju.listener;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
//<listener>
//<listener-class>com.moju.listener.MyListener</listener-class>
//</listener>
//@WebListener
public class MyListener implements ServletRequestAttributeListener, ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {


    static int count = 0;

    public MyListener() {
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {

        System.out.println("contextInit==================");

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("destory------------------------");
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("createSessoin ===========");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        /* Session is destroyed. */
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent sbe) {

      /*  String name = sbe.getName();
        System.out.println(name);

        HttpSession session = sbe.getSession();

        Object userName = session.getAttribute("user");
        System.out.println(userName+"-============================");*/


    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent sbe) {



    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent sbe) {
        /* This method is called when an attribute is replaced in a session. */
    }
}
